<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue生命周期函数</title>
    <script src="https://unpkg.com/vue@next"></script>
    <!-- 
        1.父子组件的区别,调用的是父组件,被调用的是子组件
        2.$attrs.classs是子组件调用父组件上的class
     -->
    <style>
        .red{
            color: red;
        }
        .green{
            color: green;
            background-color:beige
        }
    </style>
</head>
<body>
    <div id="root"></div>
    <script>
        // vue的生命周期函数
        const app = Vue.createApp({
            data() {
                return {
                    styleObject: {
                        // red: true,
                        green: true

                    }
                }
            },
            template: `
            <div class="red">Hello world
            <demo :class="styleObject"/>    
            </div>
            `
        });
        // root组件上面再创建一个组件
        app.component('demo',{
            template:`
            <div :class="$attrs.class">single</div>
            <div >single</div>
            `
        })
        const vm = app.mount('#root');
    </script>
</body>
</html>